package com.wzd.mphelper.mphelpertest.controller;

import com.wzd.mphelper.mphelpertest.dto.request.SeedBeforePlanLandReqDTO;
import com.wzd.mphelper.mphelpertest.dto.response.SeedBeforePlanLandRespDTO;
import com.wzd.mphelper.mphelpertest.entity.SeedBeforePlanLand;
import com.wzd.mphelper.mphelpertest.service.ISeedBeforePlanLandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class SeedBeforePlanLandController {

    @Autowired
    private ISeedBeforePlanLandService seedBeforePlanLandService;

    @PostMapping("/saveSeedBeforePlanLands")
    public void saveSeedBeforePlanLands(@RequestParam("plantCycleId") Long plantCycleId) {
        List<SeedBeforePlanLand> seedBeforePlanLands = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            SeedBeforePlanLand seedBeforePlanLand = new SeedBeforePlanLand();
            seedBeforePlanLand.setTntId("dhzy");
            seedBeforePlanLand.setIdytpCd("dhzy");
            seedBeforePlanLand.setCompanyId("1");
            seedBeforePlanLand.setCompanyName("1");
            seedBeforePlanLand.setLandNo(i + "");
            seedBeforePlanLand.setPlantCycleId(plantCycleId);
            seedBeforePlanLands.add(seedBeforePlanLand);
        }
        seedBeforePlanLandService.saveSeedBeforePlanLands(seedBeforePlanLands);
    }

    @PostMapping("/queryAll")
    public List<SeedBeforePlanLandRespDTO> queryAll(@RequestBody SeedBeforePlanLandReqDTO dto) {
        return seedBeforePlanLandService.queryAll(dto);
    }

    @PostMapping("/list")
    public List<SeedBeforePlanLand> list(@RequestBody SeedBeforePlanLandReqDTO dto) {
        return seedBeforePlanLandService.list(dto);
    }
}
